{% extends "student/base.html" %}

{% block title %}教务管理系统 --学生选课{% endblock %}

{% block page_content %}
    <!--
    这里的布局大概是这样的：

    可选课程                                 已选课程
    课程1     选课                           课程6     退课
    课程2     选课                           课程7     退课
    ...                                     ...
    ...                                     ...

    -->
    <div class="row">
        <div class="col-sm-4">
            <h1 align="left">可选课程</h1>
        </div>
        <div class="col-sm-4">
            <h1 align="center">已选课程</h1>
        </div>
        <div class="col-sm-4">
            <h1 align="right">备选课程</h1>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-4" style="background-color:lavender;">
            <!-- 在这里列出可选课程 -->
            <ul class="courses">
                {% if open %}
                    {% for section in section_list %}
                        {% if section.section_id %}
                            <li class="course">
                                <div class="course-content">
                                    <div class="course-body">
                                        {{ section.course.course_name }}
                                    </div>
                                    <div class="course-footer">
                                        <a href="{{ url_for('std.student_register_for_course', section_id=section.section_id, isPrimary=True) }}">
                                            <span class="label label-primary">选课</span>
                                        </a>
                                        <a href="{{ url_for('std.student_register_for_course', section_id=section.section_id, isPrimary=False) }}">
                                            <span class="label label-primary">设为备选</span>
                                        </a>
                                        <a href="{{ url_for('std.student_view_course_information', section_id=section.section_id) }}">
                                            <span class="label label-primary">查看课程信息</span>
                                        </a>
                                    </div>
                                </div>
                            </li>
                        {% endif %}
                    {% endfor %}
                {% else %}
                    选课时间已经截止，选课已关闭！
                {% endif %}
            </ul>
        </div>

        <div class="col-sm-4" style="background-color:lavenderblush;">
            <!-- 在这里列出已选课程 -->
            {% if taken_course_list %}
                <ul class="courses">
                    {% for taken in taken_course_list %}
                        {% if taken.section_id %}
                            <li class="course">
                                <div class="course-content">
                                    <div class="course-body">
                                        {{ taken.course.course_name }}
                                    </div>
                                    <div class="course-footer">
                                        <a href=""
                                           data-toggle='modal'
                                           data-target='#my_modal_student_delete_section_primary{{ taken.section_id }}'>
                                            <span class="label label-primary">退课</span>
                                        </a>
                                        <a href="{{ url_for('std.student_view_course_information', section_id=taken.section_id) }}">
                                            <span class="label label-primary">查看课程信息</span>
                                        </a>
                                    </div>
                                </div>
                            </li>
                        {% endif %}
                    {% endfor %}
                </ul>
            {% else %}
                暂无已选课程
            {% endif %}
        </div>

        <div class="col-sm-4" style="background-color:lavender;">
            <!-- 在这里列出已经作为备选的课程 -->
            {% if alternative_course_list %}
                <ul class="courses">
                    {% for taken in alternative_course_list %}
                        {% if taken.section_id %}
                            <li class="course">
                                <div class="course-content">
                                    <div class="course-body">
                                        {{ taken.course.course_name }}
                                    </div>
                                    <div class="course-footer">
                                        <a href=""
                                           data-toggle='modal'
                                           data-target='#my_modal_student_delete_section_non_primary{{ taken.section_id }}'>
                                            <span class="label label-primary">退课</span>
                                        </a>
                                        <a href="{{ url_for('std.student_view_course_information', section_id=taken.section_id) }}">
                                            <span class="label label-primary">查看课程信息</span>
                                        </a>
                                    </div>
                                </div>
                            </li>
                        {% endif %}
                    {% endfor %}
                </ul>
            {% else %}
                暂无备选课程
            {% endif %}
        </div>
    </div>

    {% for taken in taken_course_list %}
        {% if taken.section_id %}
            <!--MODAL-->
            <div class="modal fade" role="dialog" id="my_modal_student_delete_section_primary{{ taken.section_id }}">
                <div class="modal-dialog">

                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">提示</h4>
                        </div>
                        <div class="modal-body">
                            <p>您将退选这门课，确定要继续吗？</p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-ok btn-danger"><a
                                    href="{{ url_for('std.student_cancel_course', section_id=taken.section_id, isPrimary=True) }}">确定</a>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
    {% endfor %}

    {% for taken in alternative_course_list %}
        {% if taken.section_id %}
            <!--MODAL-->
            <div class="modal fade" role="dialog"
                 id="my_modal_student_delete_section_non_primary{{ taken.section_id }}">
                <div class="modal-dialog">

                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">提示</h4>
                        </div>
                        <div class="modal-body">
                            <p>您将取消备选这门课，确定要继续吗？</p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-ok btn-danger"><a
                                    href="{{ url_for('std.student_cancel_course', section_id=taken.section_id, isPrimary=False) }}">确定</a>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
    {% endfor %}
{% endblock %}

